using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using log4net;
using WEB.BLL.Entities;
using WEB.Exceptions;
namespace WEB.BLL.Services
{
	#region ClientService

	/// <summary>
	/// DesktopService object for Ibatis mapped table 'Desktop'.
	/// </summary>
	public class ClientService : IClientService
	{
		private static readonly ILog log = LogManager.GetLogger(typeof(ClientService).Name);
	  	private static volatile ClientService _ClientService = null;
        public static ClientService GetInstance()
        {
            if (_ClientService == null)
            {
                lock (typeof( ClientService))
                {
                    if (_ClientService == null) // double-check
                        _ClientService = new ClientService();
                }
            }
            return _ClientService;
        }
		public ClientService()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public IList<ClientEntity> Find(ClientEntity obj)
        {
            try
            {
                IList<ClientEntity> resul = ExecuteQueryForList<ClientEntity>("ClientSearch", obj);
                return resul;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        public ClientEntity LoadByUsername(ClientEntity obj)
        {
            try
            {
                return ExecuteQueryForObject<ClientEntity>("ClientLoadByUsername", obj);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }

        public int UpdatePassword(ClientEntity objE)
        {
            try
            {
                ExecuteUpdate("ClientUpdatePass", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
    }
    #endregion
}
